<template>
	<view>
		<view>
			<page-list :dataArr="noList" @listDetail="listDetail"></page-list>
			<uni-load-more v-if="morePage == 1" :loadingType="loadingType" :contentText="contentText"></uni-load-more>
			<!-- <sc-no url=""></sc-no> -->
		</view>
	</view>
</template>

<script>
	import {noticeList} from '@/common/index.js';
	import List from '@/mixins/list.js';
	import uniLoadMore from '@/components/uni-load-more.vue';
	import pageList from './list.vue';
	import scNo from '@/components/sc-no/sc-no.vue';
	export default {
		components:{
			uniLoadMore,pageList
		},
		data() {
			return {
				noList:[],
				morePage:1
			};
		},
		mixins:[List],
		methods:{
			listDetail(item){
				uni.navigateTo({
					url:'/pageD/noticDetail?id='+item.id
				})
			},
			getData(){
				noticeList({page:this.page}).then(res=>{
					if(res.code == 1){
						const data = res.msg.data;
						if(res.msg.data.length>0){
							this.noList = data;
							this.loadingType = res.msg.last_page > 1 ? 0 : 2;
							this.morePage = res.msg.last_page > 1 ? 1 : 2
							this.page++;
							uni.hideNavigationBarLoading();
							uni.stopPullDownRefresh();//得到数据后停止下拉刷新
						}else{
							this.noList = [];
						}
					}
				}).catch()
			},
			getmoreNews(){
				if (this.loadingType !== 0) {//loadingType!=0;直接返回
					return false;
				}
				this.loadingType = 1;
				uni.showNavigationBarLoading();//显示加载动画
				noticeList({page:this.page}).then(res=>{
					if(res.code == 1){
						const item = res.msg;
						if(item.data.length>0){
							this.noList = this.noList.concat(item.data);
							this.loadingType = item.last_page > 1 ? 0 : 2;
							this.page++;
							uni.hideNavigationBarLoading();
						}else{
							this.loadingType = 2;
							uni.hideNavigationBarLoading();
						}
					}
				}).catch()
			},
		}
	}
</script>
<style>
	page{
		background-color: #FFFFFF;
	}
</style>
<style lang="less">
	.list{
		padding: 30upx;
		box-sizing: border-box;
		.list-flex{
			display: flex;
			align-items: center;
			justify-content: space-between;
			// border-bottom: 2upx solid #F9F9F9;
			// padding-bottom: 20upx;
			text{
				font-size: 28upx;
				flex: 1;
			}
		}
	}

</style>
